﻿function getBannerImages(spWeb, spList, spFolder, ShowColumnName, UrlColumnName, CommentsColumnName, container, slr_settings) {
    $.getJSON("/_vti_bin/listdata.svc/" + spList + "?$filter=endswith(Path,'" + spFolder + "') and " + ShowColumnName + " eq true")
            .done(function (data) {
                //Append results to container as a number of li's <li><a><img>:
                //Run $(containerId).easySlider(...);
                var images = data.d.results;
                var imgCont = $(container + ' ul');
                for (var itemIndex in images) {
                    var image = images[itemIndex];

                    var imgURL = "#";
                    if (image[UrlColumnName] != null) {
                        var imgURL = image.URL.toString();
                        if (imgURL.indexOf(",") != -1) {
                            imgURL = imgURL.split(',')[0]
                        }
                    }

                    imgCont.append("<li><a href='" + imgURL + "'><img src='" + image.Path + "/" + image.Name + "' alt='" + image[CommentsColumnName] + "' /></a></li>");
                }

                $(container).easySlider(slr_settings);

            })
            .fail(function () {
                console.log("error");
            });
}